{include file="../include.tpl"}
<body>
{literal}
<style>
#ulList{list-style:none; padding:0; margin:0;width:97%;}
#ulList li{float:left;width:110px;height:140px;position: relative;}
#ulList li img{width:100px;height:90px; cursor:pointer;}
#ulList li div{position:absolute; top:100px;left:5px;}
.tblFile td{border:#CCC 1px solid}
#filelist div{height:30px; line-height:30px;}
.tblright td{padding:0;}
</style>

{/literal}
<iframe name="iframeSubmit" id="iframeSubmit" src="about:blank" style="display:none;"></iframe>
{include file='header.tpl'}

<table width="1000" style="margin:auto;" border="0" cellpadding="0" cellspacing="0">
   
  <tr>
    
    <td valign="top" ><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      
      <tr>
        <td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
 
          <tr>
            <td>
            <div id="users-contain" class="ui-widget" style="width:100%;">
	<form id="form" action="?act={$act}&op=saveInfo" method="post" target="iframeSubmit">
	<table id="users" class="ui-widget ui-widget-content">
		<tbody>
         <tr>
              <td align="left" valign="top" width="600">
                 <table width="100%">
                 <tr><td id="tdShowImg" colspan="2" height="450" align="center" style="text-align:center" valign="middle">
                  </td></tr>
                 <tr><td>图片编号:<span id="idid">{$f.fid}</span></td><td>上传:<span id="uploader">{$f.uname}</span></td></tr>
                 <tr><td>图片名称:<input id="name" type="text" name="dbmark" value="{$f.mark}" size="30"/></td><td rowspan="3">使用限制<br/><input type="text" value="{$f.limitUse}" name="dblimitUse" size="30"/></td></tr>
                 <tr><td>作者:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="author" type="text" name="dbauthor" value="{$f.author}" size="30"/></td></tr>
                 <tr><td>出处说明:<input type="text" id="instro" name="dbinstro" value="{$f.instro}" size="30"/></td></tr>
                 </table> 
              </td>
              <td align="left" valign="top">
 				<table width="100%" class="tblright">
                 <tr><td align="left" valign="top" style="padding:0; border:none;">
                 <table width="100%" cellpadding="0" cellspacing="0" style="margin:0;">
                 <tr><td colspan="2">添加目录</td></tr>
                 <tr><td width="50">品牌</td><td><select id="brand" did="1" sel="{$f.brandId}" name="dbbrandId"></select></td></tr>
                 <tr><td>产品</td><td><select id="car" name="dbcarId" sel="{$f.carId}"></select></td></tr>
                 <tr><td>类型</td><td><select id="type" did="14" name="dbtypeId" sel="{$f.typeId}"></select></td></tr>
                 <tr><td>分类</td><td><select id="style" did="17" name="dbstyleId" sel="{$f.styleId}"></select></td></tr>
                 <tr><td>年份</td><td><select id="year" name="dbyear" sel="{$f.year}"></select></td></tr>
                 <input type="hidden" id="brandName" name="dbbrandName"/>
                 <input type="hidden" id="carName" name="dbcarName"/>
                 <input type="hidden" id="typeName" name="dbtypeName"/>
                 <input type="hidden" id="styleName" name="dbstyleName"/>
                 <input type="hidden" id="id" name="id" value="{$f.id}"/>
                 </table>
                 </td></tr>
                 <tr><td style="padding:0; border:none;">
                 <table width="100%" cellpadding="0" cellspacing="0" style="margin-top:10px; margin-bottom:0">
                 <tr><td >设置关键词</td></tr>
                 <tr><td>
                 <textarea id="keywords" name="dbkeywords">{$f.keywords}</textarea>
                 </td></tr>
                 
                 </table>
                 </td></tr>
                 <tr><td style="padding:0; border:none;"><table width="100%" cellpadding="0" cellspacing="0" style="margin-top:10px; margin-bottom:0">
                 <tr><td >设置专题</td></tr>
                 <tr><td>
                 <textarea id="zhuanTi" name="dbzhuanTi">{$f.zhuanTi}</textarea>
                 </td></tr>
                 
                 </table></td></tr>
                 <tr><td style="padding:0; border:none;"><table width="100%" cellpadding="0" cellspacing="0" style="margin-top:10px;">
                 <tr><td >设置有效期限</td></tr>
                 <tr><td>
                  <input type="text" name="dbavaliDate" id="avaliDate" value="{$f.avaliDate}"/>
                 </td></tr>
                 
                 </table></td></tr>
                 <tr><td><button id="btnPost">完成发布</button></td></tr>
                 <tr><td><button id="btnUnPost">下架</button></td></tr>
                 </table> 
              </td>
         </tr>
		</tbody>
	</table>
    </form>
    <input type="hidden" id="act" value="{$act}"/>
</div>
 </td>
          </tr>
        </table>
          </td>
      </tr>
    </table></td>
    
  </tr>
     <tr>
        <td  height="30" valign="middle">
     
    </td>
  </tr>  <tr>
    <td valign="middle">
     {include file='footer.tpl'} 
    </td>
  </tr>
</table>
</body>
 {literal}
<script type="text/javascript">
// Custom example logic
$(function() {
	setHeaderPos("素材信息");
		$( "input[type=submit],button" )
			.button()
			.click(function(event) {
			    var bid = $(event.target)[0].id;
	            if(bid=="")
				{
					bid = $(event.target).parent()[0].id;
				}
                if(bid=="btnPost")
			    {
			     	$("#form").submit();   
			    }
				else if(bid=="btnUnPost")
				{
					$.get("?act="+$("#act").val()+"&op=saveInfo&isPost=-1&id="+$("#id").val()+"&src=ajax",function(data){
						alert("下架成功");
						});
				}
				return false;
		});
 
		for(i=2013;i<new Date().getFullYear()+2;i++)
		{
			$("#year").append("<option>"+i+"</option>");
		}
		$("#year").val(new Date().getFullYear());
        initSelect("brand",$("#brand").attr("did"));
		initSelect("type",$("#type").attr("did"));
		//initSelect("style",$("#style").attr("did"));
		$("#style").html("<option value='0'>选择</option>");
		$("#car").html("<option value='0'>选择</option>");
		$("#brand").change(function(){
			$("#brandName").val($("#brand").find("option:selected").text());
		    initSelect("car",$("#brand").val());
		});
		$("#car").change(function(){
			$("#carName").val($("#car").find("option:selected").text());
		});
		$("#style").change(function(){
			$("#styleName").val($("#style").find("option:selected").text());
		});
		$("#type").change(function(){
		    initSelect("style",$("#type").val());
			$("#typeName").val($("#type").find("option:selected").text());
		});
		$("#avaliDate").datepicker();
 
		if($("#year").attr("sel")!="")
		{
			$("#year").val($("#year").attr("sel"));
		}
});
function initSelect(obj,id)
{
	$.get("?act="+$("#act").val()+"&op=ajaxType&id="+id,function(data){
		var json = eval("("+data+")");		   
		if(json.length>0)
		{
			selop = "<option value='0'>选择</option>";
			for(i=0;i<json.length;i++)
			{
				selop = selop+"<option value='"+json[i].id+"'>"+json[i].name+"</option>";
			}
			//alert(id);
			$("#"+obj).html(selop);
		}
		else
		{
		    $("#"+obj).html("<option value='0'>无选项 不用选择</option>");
		}
		if($("#"+obj).attr("sel")!="")
		{
			$("#"+obj).val($("#"+obj).attr("sel"));
			$("#"+obj).change();
		}
		if(obj=="brand")
		{
		    $("#"+obj).val("2");
			initSelect("car",$("#brand").val());
		}
	});
}
function saveResult(st)
{
	if(st==1)
	{
		alert("发布成功");
	}
}
</script>
{/literal}
